package com.bjfu.controller;

import com.bjfu.dto.MemberRequestDTO;
import com.bjfu.dto.QuestionDTO;
import com.bjfu.service.GeneralService;
import com.bjfu.service.UserService;
import com.bjfu.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/Visitor")
public class UserController {

    @Autowired
    private UserService userService;

    //根据id获取全部提问
    @GetMapping("/getQuestions")
    public Result getQuestions(@RequestParam Long user_id) {
        return userService.getQuestions(user_id);
    }

    //根据状态获取提问
    @GetMapping("/getQuestionsByStatus")
    public Result getQuestionsByStatus(@RequestParam Long user_id,Integer status) {
        return userService.getQuestionsByStatus(user_id,status);
    }
    @GetMapping("/getReply")
    public Result getReply(@RequestParam Long question_id) {
        return userService.getReply(question_id);
    }
    @PostMapping("/submitQuestion")
    public Result submitQuestion(@RequestBody QuestionDTO questionDTO) {
        System.out.println(questionDTO);
        return userService.submitQuestion(questionDTO);
    }

}
